	Ext.onReady(function()
			{
	     	   		var tuneStore = new Ext.data.JsonStore({
			        autoLoad: true,  //autoload the data
			        url: 'TuneAction_jsonList.action',
			        id: 'tuneStore',
			        root: 'tuneBasicList',
			        fields: ['tuneID',
						     'car.manufacturer.name',
						     'car.modelName',
						     'performancePoints',
						     'car.driveTrain.name',
						     'tyresFront',
						     'tyresRear',
						     'tuner.name',
						     'rating']
					}); 

			    var tb = new Ext.Toolbar({

			        items: [
			            {text: 'Add', handler: addTune},
			            new Ext.menu.Separator(),
			            {text: 'Edit', handler: editTune},
			            new Ext.menu.Separator(),
			            {text: 'View', handler: viewTune},
			            new Ext.menu.Separator(),
			            {text: 'Delete', handler: deleteTune}
			        ],
			        autoWidth: false
			        
			    });
				            	 
				var tunesGrid = new Ext.grid.GridPanel({
				    store: tuneStore,
				    stripeRows: true,
				    columns: [
				              {header: "Tune ID", width: 60, sortable: true, dataIndex: 'tuneID'},
				              {header: "Manufacturer", width: 180, sortable: true, dataIndex: 'car.manufacturer.name'},
				              {header: "Model", width: 245, sortable: true, dataIndex: 'car.modelName'},
				              {header: "PP", width: 50, sortable: true, dataIndex: 'performancePoints'},
				              {header: "Drive", width: 50, sortable: true, dataIndex: 'car.driveTrain.name'},
				              {header: "Tyres F", width: 60, sortable: true, dataIndex: 'tyresFront'},
				              {header: "Tyres R", width: 60, sortable: true, dataIndex: 'tyresRear'},
				              {header: "Tuner", width: 245, sortable: true, dataIndex: 'tuner.name'},
				              {header: "Rating", width: 50, sortable: true, dataIndex: 'rating'}
				                                          
				          ],
				    title: 'Tunes',
				    id: 'tunesGrid',
				    bbar: tb,
				    autoHeight: true,
				    width: 1000
				    
				    
				});

				var rowIndex = -1;

				tunesGrid.on('rowcontextmenu', function(grid, row, e)
				{
					rowIndex = row;

					var tuneID = grid.getStore().getAt(rowIndex).json.tuneID;
					
					grid.getView().focusRow(rowIndex);
					grid.getSelectionModel().selectRow(rowIndex);
		
					var contextMenu = new Ext.menu.Menu();
				
					contextMenu.add(
					      new Ext.menu.Item({text: 'Add', handler:  addTune}),
					      new Ext.menu.Separator(),
					      new Ext.menu.Item({text: 'Edit', handler:  editTune}),
					      new Ext.menu.Item({text: 'View', handler:  viewTune}),
					      new Ext.menu.Separator(),
					      new Ext.menu.Item({text: 'Delete', handler:  deleteTune})
					    );

					    e.stopEvent();
					    contextMenu.showAt(e.getXY());
				});

				tunesGrid.on('rowclick', function(grid, row, e)
				{
					rowIndex = row;
				});

			    function addTune()
			    {
					var url = contextPath + "/administrator/ProviderAction_addInput.action";
					window.location = url;
			    }

			    function editTune()
			    {
					var url = contextPath + "/administrator/ProviderAction_editInput.action?provider.repositoryUUID=";
					var repositoryUUID = providersGrid.getStore().getAt(rowIndex).json.repositoryUUID;
					url += repositoryUUID;
					window.location = url;
			    }

			    function viewTune()
			    {
					var url = contextPath + "/TuneAction_gotoDetail.action";
					window.location = url;
			    }

			    function deleteTune()
			    {
					var url = contextPath + "/administrator/ProviderAction_delete.action?provider.repositoryUUID=";
					var repositoryUUID = providersGrid.getStore().getAt(rowIndex).json.repositoryUUID;
					url += repositoryUUID;
					window.location = url;
			    }
				
			    tunesGrid.render('tunes-grid'); 
			
			});